<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function randomSort2(arr) {
      let index, randomIndex, len = arr.length;
      for (index = 0; index < len; index++) {
        randomIndex = Math.floor(Math.random() * (len - index)) + index;
        [arr[randomIndex], arr[index]] = [arr[index], arr[randomIndex]];
      }
      return arr;
    }
    const arr = [5, 4, 3, 2, 1];
    console.log(randomSort2(arr));

  </script>
</body>

</html>